from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
import os

from app import app
import config

server = None
if config.HTTPS:
    server = HTTPServer(WSGIContainer(app), ssl_options={
        "certfile": config.HTTPS_CERT_FILE,
        "keyfile": config.HTTPS_KEY_FILE
    })
else:
    server = HTTPServer(WSGIContainer(app))
server.listen(config.SERVER_PORT)
IOLoop.instance().start()
